package com.pengtu.gsj.controller.dl;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.pengtu.gsj.controller.base.DefaultBaseController;
import com.pengtu.gsj.dao.base.Page;
import com.pengtu.gsj.dao.base.QueryFilter;
import com.pengtu.gsj.entity.dl.TunnelInfo;
import com.pengtu.gsj.service.dl.TunnelinfoService;

@Controller
@RequestMapping("tunnel")
public class TunnelInfoController extends DefaultBaseController{

	@Autowired
	private TunnelinfoService tunnelinfoService;
	
	/**
	 * 
	 * showListInfo:
	 * 适用:跳转到显示隧道记录列表
	 * @return 
	 * @exception 
	 * @since  1.0.0
	 */
	@RequestMapping("listInfo")
	public String showListInfo(){
		return "yh/tunnel_list";
	}
	
	/**
	 * 
	 * getTunnelInfoList:
	 * 适用: jqgrid请求列表数据
	 * @param page
	 * @param request
	 * @return 返回列表记录及页面相关信息
	 * @exception 
	 * @since  1.0.0
	 */
	@RequestMapping(value="list", produces = "application/json; charset=utf-8")
	@ResponseBody
	public Page<TunnelInfo> getTunnelInfoList(Page<TunnelInfo> page, HttpServletRequest request){
		QueryFilter queryFilter = QueryFilter.buildFromHttpRequest(request);
		if (!page.isOrderBySetted()) {
			page.setOrderBy("createDate");
			page.setOrder(Page.DESC);
		}
		page = tunnelinfoService.findTunnelinfos(page, queryFilter);
		return page;
	}
}
